package com.huaishushu.Utils;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * @Author HuaiShuShu
 * @Date 2023/5/23 15:49
 * @PackageName:com.itheima.service.impl
 * @Description: 发送邮件的工具类
 * @Version 1.0
 */
@Component
public class SendMailUtils {

    @Autowired
    private JavaMailSender javaMailSender;


    //发送人(我们自己的邮箱)
    @Value("${myMail.from}")
    private String from;

    //接收人
    @Value("${myMail.to}")
    private String to;

    //标题
    @Value("${myMail.subject}")
    private String subject;

    public void sendMail(String code) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(from+"(吃饱饱坏蜀黍)");
        message.setTo(to);
        message.setSubject(subject);
        message.setText(code);

        javaMailSender.send(message);
    }
}






